#include<iostream>
#include<cstdio>
#include<unistd.h>

int main()
{
    printf("进程替换之前！：\n");
    char* const argv[]={
        (char* const)"yuejianhua",
        (char* const)"jinzhiqi",
        NULL,
    };
    char* const env[]={
        (char* const)"other=12345",
        (char* const)"n1=45612",
        (char* const)"n2=56784",
        (char* const)"n3=12034",
        NULL,
    };
    int ret=execvpe("./text",argv,env);
    //int ret=execvp("./text",argv);
    /* char* const argv[]={
        (char* const)"ls",
        (char* const)"-a",
        (char* const)"-l",
        NULL,
    };
    int ret=execv("/bin/ls",argv); */
    /* const char* env[]={
        "other=12345",
        "n1=45612",
        "n2=56784",
        "n3=12034",
        NULL,
    };
    int ret=execle("./text","text",NULL,env); */
    /* int ret=execlp("ls","ls","-a","-l",NULL);
    (void)ret; */
    if(ret==-1)
    printf("execlp fail!\n");
    printf("进程替换之后！：\n");
    return 0;
}
/* int main()
{
    printf("进程替换之前！\n");
    int ret=execl("/bin/ls","ls","-a","-l",NULL);
    //进程替换成功后后续代码不会执行
    //只有进程替换出错后才会执行后续代码，并设置错误码
    (void)ret;
    printf("进程替换之后！\n");
    return 0;
} */
